<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/wx/page/session.jsp"%>
<c:set var="userId" value="${param.userId}" />
<c:set var="deptId" value="${param.deptId}" />
<c:set var="deptCode" value="${param.deptCode}" />
<c:set var="deptParentId" value="${param.deptParentId}" />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <title>任务大厅</title>
    <link rel="stylesheet" href="${ctx}/wx/css/default.css"/>
    <link rel="stylesheet" href="${ctx}/wx/css/picker.css"/>
    <script type="text/javascript" src="${ctx}/wx/js/picker.min.js"></script>
    <script type="text/javascript" src="${ctx}/wx/js/picker.data.js"></script>
    <script type="text/javascript" src="${ctx}/wx/js/xtable.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/util.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/interface/DeptService.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/interface/TaskService.js"></script>
    <script type="text/javascript" src="${ctx}/wx/js/alert.js"></script>
</head>
<body>
    <p class="contact-input">
        <select id="deptId" name="deptId" onchange="getTaskPage()">
            <option value="">全部信息部</option>
        </select>
    </p>
    <p class="contact-input">
        <input type="search" id="taskLoadingArea" name="taskLoadingArea" placeholder="装货地" onfocus="picker3(this)" required readonly />
    </p>
    <p class="contact-input">
        <input type="search" id="taskUnloadingArea" name="taskUnloadingArea" placeholder="卸货地" onfocus="picker3(this)" required readonly />
    </p>
    <SCRIPT LANGUAGE="JavaScript" type="">
    var taskThead = new Array(
//            new XThead("任务"),
            new XThead("任务大厅"),
            new XThead("剩余车辆")
    );

    var taskXTable = new XTable("task", taskThead);

    taskXTable.XTbodyArray = function (model) {
        var href = "<table  style='background-color: white'><tr><td style='height: 5px'></td></tr><tr>";
        href += "<td style='border-bottom: 1px #c9c9c9 solid;'>";
        href += "<p>&nbsp;" + model.dept.deptName + "</p>";
        href += "<p style='color: blue;'>&nbsp;装：" + model.taskLoadingArea + "</p>";
        href += "<p style='color: green; border-bottom: 1px #c9c9c9 solid;'>&nbsp;卸：" + model.taskUnloadingArea + "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + model.taskUnloadingAddress + "</p>";
        href += "<table><tr><td>&nbsp;" + new Date(model.taskCreateTime).Format("MM/dd hh:mm") + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + model.taskGoodsStandard + "</td><td style='text-align:right;'>" + model.taskFreightPrice + "元/吨&nbsp;</td></tr></table>";
        href += "</td>";
        href += "</tr></table>";
        var href2 = "<table width='100%' height='100%'><tr><td style='width:100%; height:100%; vertical-align: middle; background:#FFFFFF url(${ctx}/wx/images/telphone.png;)  no-repeat center; font-weight:bold; border-bottom: 1px #c9c9c9 solid;'><a href='tel:" + model.dept.deptLinkmanMobile + "'>" + (model.taskTruckTotalNum  - model.taskTruckOccupyNum) + "&nbsp;&nbsp;&nbsp;</a></td></tr></table>";
        var array = new Array(
//                new XTbody("task", href1),
                new XTbody("task", href),
                new XTbody("task", href2, null, null, null, "center")
        );

        return array;
    }
    taskXTable.getXList = function (page){
        var dept = new Dept();
        dept.deptCode = "${deptCode}".substring(0, 4);
        var task = new Task();
        task.dept = dept;
        task.taskPublishState = true;
        task.deptId = dwr.util.getValue("deptId");
        task.taskLoadingArea = dwr.util.getValue("taskLoadingArea");
        task.taskUnloadingArea = dwr.util.getValue("taskUnloadingArea");
        task.pageIndex = page;
        task.pageSize = taskXTable.pageSize;
        TaskService.selectTaskList(task, function(list){taskXTable.addTable(list);});
    }
    function getTaskPage(){
        var dept = new Dept();
        dept.deptCode = "${deptCode}".substring(0, 4);
        var task = new Task();
        task.dept = dept;
        task.taskPublishState = true;
        task.deptId = dwr.util.getValue("deptId");
        task.taskLoadingArea = dwr.util.getValue("taskLoadingArea");
        task.taskUnloadingArea = dwr.util.getValue("taskUnloadingArea");
        TaskService.selectTaskNum(task, function(num){taskXTable.setTotalPage(num);});
    }
    </SCRIPT>
</body>
</html>
<script type="text/javascript">
    function picker3(input) {
        new Picker({
            //"title": '请选择',//标题(可选)
            "defaultValue": input.value,//默认值-多个以空格分开（可选）
            "data": cityData,//数据(必传)
            "keys": {
                "id": "Code",
                "value": "Name",
                "childData": "level"//最多3级联动
            },//数组内的键名称(必传，id、text、data)
            "callBack": function (value, id) {
                //回调函数（val为选择的值）
                input.value = value;
                getTaskPage();
            }
        });
    }

    var dept = new Dept();
    dept.deptCode = "${deptCode}".substring(0, 4);
    DeptService.selectDeptList(dept, callbackSelectDeptList);

    function callbackSelectDeptList(list) {
        dwr.util.addOptions("deptId", list, "deptId", "deptName");
        getTaskPage();
    }
</script>